# SPDX-FileCopyrightText: 2024 Duncan Greatwood
#
# SPDX-License-Identifier: Apache-2.0

Making Pistache on *BSD
=======================

Pistache has been built and tested on FreeBSD, OpenBSD and NetBSD. As
of July-2024, the versions used for testing were FreeBSD 13.3,
OpenBSD 7.3 and NetBSD 10.0.

You will need to configure BSD with a working compiler.

We would recommend that you also have python installed, including pip
(use "python -m ensure-pip" if needed, and add the directory where pip
is installed to your path). Plus, we recommend installing sudo, if not
preinstalled.

You will need the following Pistache-dependencies installed:
  git (and configure as needed)
  llvm
  meson
  doxygen
  googletest (*)
  openssl
  rapidjson (*)
  howard-hinnant-date (*)
  libevent
  brotli libbrotli-dev (presuming you want to include)
  zstd libzstd-dev (presuming you want to include)
 See BSD-type-specific notes below regarding installing these
 dependencies.

Convenience shell scripts are provided to make the build. Once
dependencies are installed, at the terminal, to build do:
  bldscripts/mesbuild.sh
To test:
  bldscripts/mestest.sh
To install:
  bldscripts/mesinstall.sh


FreeBSD
=======

Typically, required packages are installed using:
  sudo pkg install <package-name>
For instance:
  sudo pkg install meson
Do this for each Pistache dependency, excluding howard-hinnant-date.


OpenBSD
=======

Typically, required packages are installed using:
  doas pkg_add <package-name>
For instance:
  doas pkg_add meson
Do this for each Pistache dependency, excluding googletest and
rapidjson.
(Note: You may use sudo instead of doas if you have installed the sudo
package and configured sudo; however, doas is often preferred on
OpenBSD.)


NetBSD
======
Typically, required packages are installed using:
  sudo pkg_in install <package-name>
For instance:
  sudo pkg_in install meson
Do this for each Pistache dependency, excluding howard-hinnant-date.

Regarding NetBSD 9.4. NetBSD 9.4 uses gcc 7.5.0, while Pistache's
build files require C++17 support, and Pistache's code uses
std::filesystem. However, gcc 7.5.0 does not work correctly with
std::filesystem when C++17 is specified. Accordingly, we have tested
with NetBSD 10.0, not 9.4. Nonetheless, it is possible that Pistache
could be made to work on NetBSD 9.* with a different compiler or
different compiler version.

Regarding the test net_test.invalid_address, it may be slow to execute
(about 2 minutes) in NetBSD. The cause is a long time out for the
system function getaddrinfo; it doesn't appear to an issue in
Pistache.


(*) Googletest, Rapidjson and Howard-hinnant-date Packages
==========================================================

These packages are provided as Pistache subprojects, and so do not
have to be installed seperately on the BSD system. Also, note that
there is no howard-hinnant-date package supplied as part of the OS by
FreeBSD 13 nor by NetBSD 10; and no googletest or rapidjson packages
supplied by OpenBSD 7. Nonetheless, if you would like to install
googletest, rapidjson and/or howard-hinnant-date manually on the BSD
system, please proceed as follows:

Googletest:
  git clone https://github.com/google/googletest.git
  cd googletest
  mkdir build
  cd build
  cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
  make
  sudo make install

Rapidjson:
  git clone https://github.com/Tencent/rapidjson/
  cd rapidjson/
  mkdir build
  cd build
  cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
  make
  sudo make install

Howard-hinnant-date:
  git clone https://github.com/HowardHinnant/date.git
  sudo mkdir /usr/local/include/date
  sudo cp -p date/include/date/date.h /usr/local/include/date/.

(Note: Typically, use doas instead of sudo on OpenBSD).


How It Works
============
Pistache on BSD works very much as it does on macOS, i.e. by using the
libevent library to provide the core event loop.
